﻿
@{
    Layout = null;
    ViewBag.Title = "Ceshi";
}

<h2>Ceshi</h2>
<script src="~/Scripts/jquery-1.10.2.js"></script>

<script type="text/javascript">

    $(function () {

        $.ajax({
            url: "http://shtdj.shanhaitian.gov.cn/AppInterface/api/User/Login",
            type: "POST",
            contentType: "application/json",
            async: true,
            data: JSON.stringify({ UserName: 'admin', UserPwd: '1qaz2wsx3edc' }),
            success: function (data, status) {

                var dd = eval(data);
                var zhi = eval(data.result);
                if (dd.code == "201") {
                    api.toast({ msg: dd.msg, location: "middle" });
                }
                else if (dd.code == "400") {
                    api.toast({ msg: dd.msg, location: "middle" });
                }
                else if (dd.code == "200") {
                    api.alert({
                        title: '消息提示',
                        msg: '登陆成功',
                        buttons: ['确定']
                    }, function (ret, err) {
                        if (ret.buttonIndex == 1) {
                            //存储Session
                            $api.setStorage('UserId', zhi.UserId);
                            $api.setStorage('UserName', zhi.UserName);
                            $api.setStorage('UserTrueName', zhi.UserTrueName);
                            $api.setStorage('UserBranchId', zhi.UserBranchId);

                            api.execScript({
                                name: 'root',
                                frameName: 'person',
                                script: 'SetUserId("' + zhi.UserId + '")'
                            });

                            api.closeFrame({
                                name: 'login'
                            });
                        }
                    });
                }
            },
            error: function (xhr, textStatus) {
                console.log('错误')
                console.log(xhr)
                console.log(textStatus)
            }
        });

    });

</script>

